var fs = require("fs");
const qs = require("qs");
var express = require("express");
// var multer = require('multer');

const jwt = require("jsonwebtoken");
const { resourceUsage } = require("process");
var routers = express.Router();
var axios = require("axios");
const { router } = require("../../app");
const { log } = require("console");
// var storage = multer.diskStorage({
//     destination:function(req,file,cb){
//         cb(null,'/publics/back-stage/img');
//     },
//     filename:function(req,file,cb){
//         cb(null,'aaa.jpg');
//     }
// });
// var upload = multer({
//     storage:storage
// })

// 页面渲染
routers.get("/admin", function (req, res) {
  res.render("back-stage/admin.html", {
    userinfo: jwt.decode(req.session.token),
  });
});
routers.get("/admin/video", function (req, res) {

  res.render("back-stage/video.html", {
    userinfo: jwt.decode(req.session.token),
  });


  let type, area, year, whetherFree;
  // 类型
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/type/s",
    headers: {
      token: req.session.token ? req.session.token : "",
    },
  })
    .then(function (data) {
      type = data.data.data;
    })
    .catch(function (error) {
      console.log(error)
      res.status(500).json({
        msg: '失败'
      })
    })
  // 地区
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/type/areaTags",
  })
    .then(function (data) {
      area = data.data.data;
    })
    .catch(function (error) {
      res.status(500).json({
        msg: "失败",
      });
    })
  // 年份
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/type/yearTags",
  })
    .then(function (data) {
      year = data.data.data;
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
  // 资费
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/type/whetherFree",
  })
    .then(function (data) {
      whetherFree = data.data.data;
      res.render("back-stage/video.html", {
        userinfo: jwt.decode(req.session.token),
        type: type,
        area: area,
        year: year,
        whetherFree: whetherFree,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
routers.get("/admin/users", function (req, res) {
  res.render("back-stage/users.html", {
    userinfo: jwt.decode(req.session.token),
  });
});
routers.get("/admin/pinglun", function (req, res) {
  res.render("back-stage/pinglun.html", {
    userinfo: jwt.decode(req.session.token),
  });
});

routers.get("/admin/actor", function (req, res) {
  res.render("back-stage/actor.html", {
    userinfo: jwt.decode(req.session.token),
  });
});
routers.get("/admin/vipgoods", function (req, res) {
  res.render("back-stage/vipgoods.html", {
    userinfo: jwt.decode(req.session.token),
  });
});
routers.get("/admin/advertisement", function (req, res) {
  res.render("back-stage/advertisement.html", {
    userinfo: jwt.decode(req.session.token),
  });
});
routers.get("/admin/payvipOrder", function (req, res) {
  res.render("back-stage/payvipOrder.html", {
    userinfo: jwt.decode(req.session.token),
  });
});
routers.get("/admin/accuse", function (req, res) {
  res.render("back-stage/accuse.html", {
    userinfo: jwt.decode(req.session.token),
  });
});
// 接口 用户
// 退出登陆
routers.post("/user/logout", function (req, res) {
  // console.log(1)
  axios({
    method: "post",
    url: "http://42.194.158.211:8081/video/user/logout",
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 通过id查询用户数据
routers.get("/user/findUserById", function (req, res) {
  // console.log(1)
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/user/findUserById",
    params: {
      userId: req.query.userId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 遍历关注
routers.get("/fan/myAttention", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/fan/myAttention",
    params: {
      userId: req.query.userId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 遍历粉丝
routers.get("/fan/myFans", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/fan/myFans",
    params: {
      userId: req.query.userId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 将用户降级
routers.put("/user/demotionUserVip", function (req, res) {
  axios({
    method: "put",
    url: "http://42.194.158.211:8081/video/user/demotionUserVip",
    params: {
      password: req.query.password,
      userId: req.query.userId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 将用户降级
routers.put("/user/upgradeUserVip", function (req, res) {
  axios({
    method: "put",
    url: "http://42.194.158.211:8081/video/user/upgradeUserVip",
    params: {
      password: req.query.password,
      userId: req.query.userId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// 将升级用户为vip,并且定义时间
routers.put("/user/upgradeUserVipAndTime", function (req, res) {
  console.log(req.query);
  axios({
    method: "put",
    url: "http://42.194.158.211:8081/video/user/upgradeUserVipAndTime",
    params: {
      password: req.query.password,
      time: req.query.time,
      userId: req.query.userId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// ------------------------------------------------------------------------------------------------------------------------------
// 分页遍历
routers.get("/user/findAllUser", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/user/findAllUser",
    params: {
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 添加
routers.post("/user/addUser", function (req, res) {
  // console.log(1)
  axios({
    method: "post",
    url: "http://42.194.158.211:8081/video/user/addUser",
    params: {
      account: req.query.account,
      password: req.query.password,
      nickname: req.query.nickname,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 删除单个数据
routers.delete("/user/deleteUser", function (req, res) {
  // console.log(1)
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/user/deleteById",
    params: {
      userId: req.query.userId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 模糊查询
routers.get("/user/findUserByAccountLikeAndNickNameLike", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/user/findUserByAccountLikeAndNickNameLike",
    params: {
      nickname: req.query.nickname,
      account: req.query.account,
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 修改用户信息
routers.put("/user/updateUsers", function (req, res) {
  axios({
    method: "put",
    url: "http://42.194.158.211:8081/video/user/updateUsers",
    params: {
      account: req.query.account,
      age: req.query.age,
      birthday: req.query.birthday,
      email: req.query.email,
      nickname: req.query.nickname,
      password: req.query.password,
      sex: req.query.sex,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// 接口 视频
// --------------------------------------------------------------------------------------------------------------------------------------
// 遍历数据
routers.get("/videoCRUD/findAllVideo", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/videoCRUD/findAllVideo",
    params: {
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// 删除单个数据
routers.delete("/videoCRUD/deleteVideo", function (req, res) {
  // console.log(1)
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/videoCRUD/deleteVideo/",
    params: {
      videoId: req.query.videoId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 模糊查询
routers.get("/videoCRUD/findLikeVideoName", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/videoCRUD/findLikeVideoName",
    params: {
      videoName: req.query.videoName,
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 审核视频
routers.post("/verify/auditVideo/", function (req, res) {
  let { verifyNumber } = req.query;
  axios({
    method: "post",
    url: "http://42.194.158.211:8081/video/verify/auditVideo",
    params: {
      passReason: req.query.passReason,
      verityNumber: verifyNumber,
      videoId: req.query.videoId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 通过id查询审核记录
routers.get("/verify/findVerifyReasonByVideoId", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/verify/findVerifyReasonByVideoId",
    params: {
      videoId: req.query.videoId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// -------------------------------------------------------------------------------------------------------------------------------------------
// 评论接口
// 遍历数据
routers.get("/findAllComment", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/findAllComment",
    params: {
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 模糊查询
routers.get("/findCommentByContentLike", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/findCommentByContentLike",
    params: {
      content: req.query.content,
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 删除主评论
routers.delete("/deleteCommentByCommentId", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/deleteCommentByCommentId",
    params: {
      commentId: req.query.commentId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 批量删除
routers.delete("/deleteCommentList", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/deleteCommentList",
    params: {
      commentId: req.query.commentId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 遍历子评论
routers.get("/findCommentSonByCommentId", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/findCommentSonByCommentId",
    params: {
      commentId: req.query.commentId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 删除子评论
routers.delete("/deleteCommentSonByCommentSonId", function (req, res) {
  console.log(req.query.commentSonId);
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/deleteCommentSonByCommentSonId",
    params: {
      commentSonId: req.query.commentSonId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 批量子评论删除
routers.delete("/deleteCommentSonList", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/deleteCommentSonList",
    params: {
      commentSonId: req.query.commentSonId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 演员接口
// --------------------------------------------------------------------------------------
routers.get("/actor/findAllActorMsgLimitPage", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/actor/findAllActorMsgLimitPage",
    params: {
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 模糊查询
routers.get("/actor/findActorsByLikeActorName", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/actor/findActorsByLikeActorNameLimitPage",
    params: {
      actorName: req.query.actorName,
      pageNow:req.query.pageNow,
      pageSize:req.query.pageSize
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 查询视频下的演员
routers.get("/actor/findAllActorsByVideoId", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/actor/findAllActorsByVideoId",
    params: {
      videoId: req.query.videoId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 查询演员下参与的视频
routers.get("/actor/findActorMessage", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/actor/findActorMessage",
    params: {
      actorId: req.query.actorId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// 添加演员
routers.put("/actor/addMoreActorMsgForVideo", function (req, res) {
  const data = req.body;
  axios
    .put(
      "http://42.194.158.211:8081/video/actor/addMoreActorMsgForVideo",
      data,
      { headers: { "Content-Type": "application/json" } }
    )
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 删除单个演员
routers.delete("/actor/deleteActorByActorId", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/actor/deleteActorByActorId",
    params: {
      actorId: req.query.actorId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 删除单个演员
routers.delete("/actor/deleteActorsByActorIds", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/actor/deleteActorsByActorIds",
    params: {
      Ids: req.query.Ids,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 修改演员信息
routers.put("/actor/updateActorMessageByActorId", function (req, res) {
  axios({
    method: "put",
    url: "http://42.194.158.211:8081/video/actor/updateActorMessageByActorId",
    params: {
      accomplishment: req.query.accomplishment,
      actorBirthday: req.query.actorBirthday,
      actorId: req.query.actorId,
      actorIntroduction: req.query.actorIntroduction,
      actorName: req.query.actorName,
      actorNation: req.query.actorName,
      actorNickName: req.query.actorNickName,
      actorOccupation: req.query.actorOccupation,
      popularity: req.query.popularity,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// ==================================================================================================
// vip商品
routers.get("/order/findAllUser", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/order/findAllUser",
    params: {
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 查询vip商品
routers.post("/order/findVipByVIPId", function (req, res) {
  axios({
    method: "post",
    url: "http://42.194.158.211:8081/video/order/findVipByVIPId",
    params: {
      vipId: req.query.vipId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 添加vip商品
routers.post("/order/addVip", function (req, res) {
  // console.log(1)
  axios({
    method: "post",
    url: "http://42.194.158.211:8081/video/order/addVip",
    params: {
      price: req.query.price,
      vipName: req.query.vipName,
      vipIntroduction: req.query.vipIntroduction,
      vipId: req.query.videoId,
      point: req.query.point,
      time: req.query.time,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 修改vip商品信息
routers.put("/order/updateVip", function (req, res) {
  axios({
    method: "put",
    url: "http://42.194.158.211:8081/video/order/updateVip",
    params: {
      price: req.query.price,
      vipName: req.query.vipName,
      vipIntroduction: req.query.vipIntroduction,
      vipType: req.query.vipType,
      time: req.query.time,
      vipId: req.query.vipId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 删除vip商品
routers.delete("/order/deleteVip", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/order/deleteVip",
    params: {
      vipId: req.query.vipId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 批量删除vip商品
routers.delete("/order/deleteVipList", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/order/deleteVipList",
    params: {
      vipId: req.query.vipId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 模糊查询
routers.get("/order/findVipBynameLike", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/order/findVipBynameLike",
    params: {
      name: req.query.name,
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// ==================================================================================================
// 广告
routers.get("/advertisement/findAllAdverLimitPage", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/advertisement/findAllAdverLimitPage",
    params: {
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// 模糊查询
routers.get(
  "/advertisement/findAdvertisementByLikeKeyWordsLimitPage",
  function (req, res) {
    axios({
      method: "get",
      url: "http://42.194.158.211:8081/video/advertisement/findAdvertisementByLikeKeyWordsLimitPage",
      params: {
        keyWords: req.query.keyWords,
        pageNow: req.query.pageNow,
        pageSize: req.query.pageSize,
      },
    })
      .then(function (data) {
        res.status(200).json({
          data: data.data,
          code: 0,
        });
      })
      .catch(function (err) {
        res.status(500).json({
          msg: "失败",
        });
      });
  }
);
// 删除单个广告
routers.delete("/advertisement/deleteAdvertisementById", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/advertisement/deleteAdvertisementById",
    params: {
      advertisementId: req.query.advertisementId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 批量删除广告
routers.delete("/advertisement/deleteAdvertisementByIds", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/advertisement/deleteAdvertisementByIds",
    params: {
      Ids: req.query.Ids,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// ======================================================================================================
// 订单
routers.get("/payVipOrder/findAllPayVipOrder", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/payVipOrder/findAllPayVipOrder",
    params: {
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 批量删除订单
routers.delete("/payVipOrder/deleteOrderList", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/payVipOrder/deleteOrderList",
    params: {
      commentSonId: req.query.commentSonId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// ======================================================================================================
// 举报
// 视频
routers.get("/video/findReportsVideo", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/findReportsVideo",
    params: {
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 评论
routers.get("/video/findReportsComment", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/findReportsComment",
    params: {
      commentType: req.query.commentType,
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});

// 删除单个举报
routers.delete("/video/deleteReportRecord", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/deleteReportRecord",
    params: {
      reportId: req.query.reportId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 删除单个举报
routers.delete("/video/deleteReportList", function (req, res) {
  axios({
    method: "delete",
    url: "http://42.194.158.211:8081/video/deleteReportList",
    params: {
      reportId: req.query.reportId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
      console.log(req.query);
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 模糊查询通过昵称账号 视频
routers.get("/video/findReportVideoByNicknameAndAccount", function (req, res) {
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/findReportVideoByNicknameAndAccount",
    params: {
      nickname: req.query.nickname,
      account: req.query.account,
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 模糊查询举报理由  视频
routers.get("/video/findReportVideoByContent", function (req, res) {
  console.log(req.query);
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/findReportVideoByContent",
    params: {
      content: req.query.content,
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 模糊查询通过昵称账号  评论
routers.get(
  "/video/findReportCommentByNicknameAndAccount",
  function (req, res) {
    axios({
      method: "get",
      url: "http://42.194.158.211:8081/video/findReportCommentByNicknameAndAccount",
      params: {
        nickname: req.query.nickname,
        account: req.query.account,
        commentType: req.query.commentType,
        pageNow: req.query.pageNow,
        pageSize: req.query.pageSize,
      },
    })
      .then(function (data) {
        res.status(200).json({
          data: data.data,
          code: 0,
        });
      })
      .catch(function (err) {
        res.status(500).json({
          msg: "失败",
        });
      });
  }
);
// 模糊查询举报理由  评论
routers.get("/video/findReportCommentByContent", function (req, res) {
  console.log(req.query);
  axios({
    method: "get",
    url: "http://42.194.158.211:8081/video/findReportCommentByContent",
    params: {
      content: req.query.content,
      commentType: req.query.commentType,
      pageNow: req.query.pageNow,
      pageSize: req.query.pageSize,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 受理举报
routers.put("/video/updateReportOne", function (req, res) {
  axios({
    method: "put",
    url: "http://42.194.158.211:8081/video/updateReportOne",
    params: {
      reportId: req.query.reportId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
// 不受理举报
routers.put("/video/updateReportTwo", function (req, res) {
  axios({
    method: "put",
    url: "http://42.194.158.211:8081/video/updateReportTwo",
    params: {
      reportId: req.query.reportId,
    },
  })
    .then(function (data) {
      res.status(200).json({
        data: data.data,
        code: 0,
      });
    })
    .catch(function (err) {
      res.status(500).json({
        msg: "失败",
      });
    });
});
module.exports = routers;
